package com.blog.Utils;

import java.time.LocalDateTime;

/**
 * @author 任浩
 * @version 1.0
 * 这是生成redis set数据结构key的工具类
 */
public class RedisKeyUtil {
    private static final String POST_SETKEYWORD_PREFIX = "like:";
    private static final String COMMENT_SETKEYWORD_PREFIX = "like:comment:";
    private static final String USER_SETKEYWORD_PREFIX = "user_like:";
    private static final String USER_ATTENTION_PREFIX = "user_attention:"; // 这是用户关注的存储的key
    private static final String USER_FANS_PREFIX = "user_fans:";  //这是用户粉丝的存储的key
    private static final String DATA_UV_PREFIX = "data:uv:";  //这是存储独立访问用户的key。
    private static final String DATA_DAU_PREFIX = "data:dau:"; //这是日访问用户的key。
    private static final String SCORE_PREFIX = "score:refresh"; //这是进行帖子热度更新的保存帖子的id。
    private static final String VIEW_COUNT = "viewCount:";  //浏览量的key前缀


    public static String init(String postId){
        return new String(POST_SETKEYWORD_PREFIX + postId);
    }

    public static String commentInit(String postId){
        return new String(COMMENT_SETKEYWORD_PREFIX + postId);
    }

    public static String userInit(String userId){
        return new String(USER_SETKEYWORD_PREFIX + userId);
    }

    public static String attention(String userId){
        return new String(USER_ATTENTION_PREFIX + userId);
    }

    public static String fans(String userId){
        return new String(USER_FANS_PREFIX + userId);
    }

    public static String uvInit(LocalDateTime date){
        String s = date.toString();
        return new String(DATA_UV_PREFIX + s);
    }

    public static String dauInit(LocalDateTime date){
        String s = date.toString();
        return new String(DATA_DAU_PREFIX + s);
    }

    public static String scoreInit(){
        return SCORE_PREFIX;
    }

    public static String getViewCountKey(String value){
        return  new String(VIEW_COUNT + value);
    }

}
